package com.crm.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.crm.entity.Business;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.time.LocalDateTime;
import java.util.List;

@Mapper
public interface BusinessMapper extends BaseMapper<Business> {
    /**
     * 新增商机
     *
     * @param business
     */
    int insert(Business business);

    /**
     * 商机分页查询
     *
     * @param beginCreateTime
     * @param endCreateTime
     * @return
     */
    List<Business> selectByBusinessList(String beginCreateTime, String endCreateTime);

    List<Business> selectByBusinessList(LocalDateTime beginCreateTime, LocalDateTime endCreateTime);

    //修改商机状态，为1就放在商机池
    @Update(" UPDATE business SET business_type = 0 WHERE id = #{businessId}")
//    @Insert("update business set business_type = 0 where reason = #{reason}")
    void updateBusiness(Integer businessId, Integer reason);
//修改合同状态，为1就放在合同池
    @Update("Update business SET contract_type = 1 where id = #{businessId}")
    void updateContractType(Long id);
}
